package com.bkhech.spring.controller;

import com.bkhech.spring.ApiResponse;
import com.bkhech.spring.domain.LevelViews;
import com.bkhech.spring.domain.Student;
import com.fasterxml.jackson.annotation.JsonView;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/my")
public class MyStudentController {

    /**
     * GET without any json view
     *
     * @return created ApiResponse<Student>
     */
    @GetMapping("/levelTwo/default")
    public ApiResponse<Student> getLevelTwoDefault() {
        return ApiResponse.success(Student.createStudent());
    }

    /**
     * GET with lowest view Public
     *
     * @return created ApiResponse<Student>
     */
    @JsonView(LevelViews.Public.class)
    @GetMapping("/levelTwo/public")
    public ApiResponse<Student> getLevelTwoPublic() {
        return ApiResponse.success(Student.createStudent());
    }

    /**
     * GET with SubPublic View which extends Public
     *
     * @return created ApiResponse<Student>
     */
    @JsonView(LevelViews.SubPublic.class)
    @GetMapping("/levelTwo/basic")
    public ApiResponse<Student> getLevelTwoBasicDetails() {
        return ApiResponse.success(Student.createStudent());
    }

    /**
     * GET with GrandPublic View which extends SubPublic,Public
     *
     * @return created ApiResponse<Student>
     */
    @JsonView(LevelViews.GrandPublic.class)
    @GetMapping("/levelTwo/all")
    public ApiResponse<Student> getLevelTwoAllDetails() {
        return ApiResponse.success(Student.createStudent());
    }

}